import request from "@/utils/request";

const LOG_BASE_URL = "/v3/manager/storeDevice";

class StoreDeviceApi {
  /**
   * 店铺与设备相关接口
   */
  static getStoreDevicePage(queryParams: FencesPageQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/page`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
  @date: 2025-01-08 18:40:42
  获取店铺可分配设备列表
  */
  static getAssignableDevice(queryParams: assignableFiltQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/assignableDevice`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
  @date: 2025-01-08 18:40:42
  店铺添加设备
  */
  static addDevice(queryParams: DeviceForm) {
    return request({
      url: `${LOG_BASE_URL}/save`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
  @date: 2025-01-08 18:40:42
  店铺编辑设备
  */
  static editDevice(queryParams: DeviceForm) {
    return request({
      url: `${LOG_BASE_URL}/update`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 删除设备类型
   *
   * @param queryParams 查询参数
   */
  static deleteSave(queryParams: string) {
    return request({
      url: `${LOG_BASE_URL}/delete/${queryParams}`,
      method: "POST",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
    });
  }
}

export default StoreDeviceApi;

/**
 * 日志分页查询对象
 */
export interface LogPageQuery {
  /** 搜索关键字 */
  keywords?: string;
  pages?: any;
  module?: string;
  operation?: string;
  content?: string;
  type?: string;
  ip?: string;
  customerId?: number;
}

/**
 * 系统日志分页VO
 */
export interface LogPageVO {
  current: number;
  pages: number;
  records: Array<any>;
  size: number;
  total: number;
}
export interface FencesPageQuery {
  /** 搜索关键字 */
  pages?: any;
  storeId?: string;
  deviceCode?: string;
  isRent: string;
  status?: string;
}
export interface assignableFiltQuery {
  /** 搜索关键字 */
  pages?: any;
  deviceTypeId?: string;
  deviceCode?: string;
  btCode?: string;
  deviceName?: string;
}
export interface storeSelectList {
  deviceId: string;
  deviceCode: string;
  id?: string;
}
export interface DeviceForm {
  [key: string]: any;
  deviceList?: storeSelectList[]; // 正确的数组类型定义
  salePrice: string; // 销售价格
  firstPrice: string; // 首付金额
  periodsNum: string; // 分期期数
  servicePrice: string; // 服务年费 / 保险费
  isRent: "RENTAL" | "SALE"; // 租售类型
  depositPrice: string; // 押金金额
  rentalPrice: {
    day: string; // 天
    mouth: string; // 月
    quarter: string; // 季
    year: string; // 年
  };
  storeId: string;
  id?: string;
}
